package demo2;

/**
 * Created with IntelliJ IDEA.
 * Description：
 * User：user
 * DATE:2021-10-29
 * Time:18:04
 */
class Animal{
    public String name;
    public Animal(String name){
        this.name = name;
    }
}
/*abstract  class A {
    public abstract  void A();
}

interface  B  extends  A{
    //接口也可以实现抽象类
}*/
// 跑 跳 飞
interface IFlying {
    void fly();
}
interface IRunning {
    void run();
}
interface ISwimming {
    void swim();
}

class Cat extends  Animal implements  IRunning{
    public Cat(String name) {
        super(name);
    }

    @Override
    public void run() {
        System.out.println("猫在跑");
    }
}
class Frog extends  Animal implements  IRunning,ISwimming{
    public Frog(String name) {
        super(name);
    }

    @Override
    public void run() {
        System.out.println("青蛙在跑");
    }

    @Override
    public void swim() {
        System.out.println("青蛙在游咏");
    }
}
class Duck extends  Animal implements  IRunning,ISwimming,IFlying{
    public Duck(String name) {
        super(name);
    }

    @Override
    public void fly() {
        System.out.println("鸭子飞");
    }

    @Override
    public void run() {
        System.out.println("鸭子跑");
    }

    @Override
    public void swim() {
        System.out.println("鸭子游泳");
    }
}


//扩展性很强
class Roobot implements  IRunning{

    @Override
    public void run() {
        System.out.println("机器人在跑");
    }
}
public class Test3 {
    public  static void func(IRunning iRunning){
        iRunning.run();
    }

    public static void main(String[] args) {
        func(new Cat("猫"));
        func(new Frog("青蛙"));
        func(new Roobot());

    }
    public static void main2(String[] args) {
        IRunning iRunning = new Cat("猫");
        IRunning iRunning2 = new Frog("青蛙");
        ISwimming iSwimming = new Duck("鸭子");
    }
    public static void main1(String[] args) {
            Animal animal = new Cat("猫");
    }
}
